/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package socof_trab1;

public class BandwithAllocation {

    private static long sizeDownloading = 0;
    private static BandwithAllocation bwa = new BandwithAllocation();

    private BandwithAllocation() {
    }

    public static BandwithAllocation getInstance() {
        return BandwithAllocation.bwa;
    }

    /**
     * Gets the size of bytes downloading at an instant
     *
     * @return
     */
    public synchronized long getSizeDownloading() {
        return BandwithAllocation.sizeDownloading;
    }

    /**
     * Sets the amount of data being downloaded before download
     *
     * @param size
     */
    public synchronized void addDownload(long size) {
        BandwithAllocation.sizeDownloading += size;
    }

    /**
     * Sets the amount of data being downloaded after download
     *
     * @param size
     */
    public synchronized void removeDownload(long size) {
        BandwithAllocation.sizeDownloading -= size;
    }
}
